﻿using LogisticsBLL.jhb;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


namespace LogisticsUI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class CustomerController : ControllerBase
    {
        private readonly customerBLL bll;
        public CustomerController(customerBLL bll)
        {
            this.bll = bll;
        }
        [Route("GetAll")]
        public List<Customer> GetAll()
        {
            List<Customer> list = bll.GetAll();
            return list;
        }
        
        public List<Customer> Getcustomer(string card, string cname, string mobile)
        {
            if (mobile==null)
            {
                mobile = "";
            }
            List<Customer> list = bll.Getcustomer(card, cname, mobile);
            return list;        
        }
        //string cname, string card,string work,string tel,string mobile,string address,string post,string email,string area
        [Route("xiugai")]
        public string Putcustomer(Customer cs)
        {
           string result = bll.update(cs);
            return result;
        }
        [HttpPost]
        public string PostAddCustomer(Customer cu)
        {
            return bll.AddCustomer(cu);
        }
    }
}
